1 program problem11203 (input, output);
\r
6 Function StrToInt(Const S: String): Integer;
\r
14 function formadaPor(s : string; c : char) : boolean;
\r
19 for i := 1 to length(s) do
\r
29 {function isAxiom(s : String): boolean; overload;
\r
37 while ((s[i] <> 'M') and (i <= length(s))) do
\r
43 if (x1 = '') or (not formadaPor(x1, '?')) then
\r
49 s := copy(s, i, length(s));
\r
50 if (s[1] <> 'M') or (s[2] <> '?') or (s[3] <> 'E') then
\r
56 x2 := copy(s, 4, length(s));
\r
57 if (not formadaPor(x2, '?')) or ((length(x1) + 1) <> length(x2)) then
\r
65 function isAxiom(x, y, z : string) : boolean; overload;
\r
68 if (length(x) + 1) <> (length(z)) then
\r
73 function isTheorem(s : string) : boolean;
\r
80 while ((s[i] <> 'M') and (i <= length(s))) do
\r
86 if (x = '') or (not formadaPor(x, '?')) then
\r
92 s := copy(s, i, length(s)); //delete from the beggining until the character before the first M
\r
99 s := copy(s, 2, length(s)); //delete the M
\r
102 while ((s[i] <> 'E') and (i <= length(s))) do
\r
108 if (y = '') or (not formadaPor(y, '?')) then
\r
114 s := copy(s, i, length(s)); //delete from the beggining until the character before the first E
\r
115 if s[1] <> 'E' then
\r
121 z := copy(s, 2, length(s)); //delete the E
\r
122 if not formadaPor(z, '?') then
\r
129 if length(y) = 1 then
\r
130 result := isAxiom(x, y, z)
\r
133 y := copy(y, 1, length(y) - 1); //borra el ultimo
\r
134 z := copy(z, 1, length(z) - 1);
\r
135 result := isTheorem(x+'M'+y+'E'+z);
\r
141 i, j, principalLoop : integer;
\r
143 letrasCorrectas : Set of char;
\r
148 //reset(input, 'input.txt');
\r
149 //reset(output, 'out.txt');
\r
152 letrasCorrectas := ['M', 'E', '?'];
\r
154 cuantos := strToInt(entrada);
\r
156 {if isAxiom('?E??') then writeLn('si') else writeLn('no');
\r
157 if isAxiom('??M?E???') then writeLn('si') else writeLn('no');
\r
158 if isAxiom('??M?E??') then writeLn('si') else writeLn('no');
\r
159 if isAxiom('?M??E??') then writeLn('si') else writeLn('no');
\r
160 if isAxiom('?M?E??') then writeLn('si') else writeLn('no');
\r
161 if isAxiom('???M?E????') then writeLn('si') else writeLn('no');
\r
162 if isAxiom('?E?M??') then writeLn('si') else writeLn('no'); }
\r
164 {if isTheorem('?E??') then writeLn('si') else writeLn('no');
\r
165 if isTheorem('??M?E???') then writeLn('si') else writeLn('no');
\r
166 if isTheorem('??M?E??') then writeLn('si') else writeLn('no');
\r
167 if isTheorem('?M??E??') then writeLn('si') else writeLn('no');
\r
168 if isTheorem('?M?E??') then writeLn('si') else writeLn('no');
\r
169 if isTheorem('???M?E????') then writeLn('si') else writeLn('no');
\r
170 if isTheorem('?E?M??') then writeLn('si') else writeLn('no');
\r
171 if isTheorem('?M???E????') then writeLn('si') else writeLn('no');}
\r
173 for principalLoop := 1 to cuantos do
\r
177 j := length(entrada);
\r
179 if not (entrada[i] in letrasCorrectas) then
\r
185 writeLn('no-theorem')
\r
188 if isTheorem(entrada) then
\r
191 writeLn('no-theorem');
\r